window.workspace = function(){
	var response  = <?#$respons?>;
	var store, win, grid, sm;
	var sid = {'refid':Ext.id(), 'sdate':Ext.id(), 'edate':Ext.id()};
	
	function openText(data){
		win && win.close();
		var html = data.get('msg');
		if(data.get('zmsg').length > 0) {
			html += '<br />回复内容:<br />'+data.get('zmsg');
		}
		win = new Ext.Window({
			title	: '留言详情[Details]',
			iconCls	: 'icon-edit',	
			width	: 760,
			items   : [{html:html}],
			closeAction : 'hide'
		});
		win.show();
	};
	
	store = new Ext.data.JsonStore({
	    autoDestroy	: true,
	    url			: '/admin/live/basic/comments/dolist.html',
	    remoteSort	: true,
	    sortInfo	: {
	    	field		: 'id',
	        direction	: 'DESC'
		},
		baseParams	: {
			start	: 0,
			limit	: main.pageSize
		},
		autoLoad		: true,
	    root			: 'dataset',
	 	totalProperty	: 'total',
	    fields			: ['id', 'refid', 'anchor', 'username', 'userid',
	         'msg', 'status', 'addtime', 'zmsg', 'zstatus', 'zaddtime']
	});
	sm   = new Ext.grid.CheckboxSelectionModel();
 	grid = {
		xtype		: 'grid',
		title		: response.title,
	    store		: store,
		region		: 'center', 
	    columns		: [
            sm,
			{header: '编号[ID]', width:60, sortable:true, dataIndex:'id'},
			{header: '主播昵称[Anchor]',  width:140, sortable:true, dataIndex:'refid', renderer:function(v, meta, obj){
				return obj.get('anchor');
			}},
			{header: '留言者[User]', width:140, sortable:true, dataIndex:'userid', renderer:function(v, meta, obj){
				return obj.get('username');
			}},
			{header: '留言内容[Comment]', width:200, dataIndex:'msg'},
			{header: '是否删除[IsDelete]',  width:60, dataIndex:'status', sortable:true, renderer:function(v){
				return response.status[v];
			}},
			{header: '留言时间[AddTime]', width:100, dataIndex:'addtime'},
			{header: '回复内容[Reply]', width:160, dataIndex:'zmsg'},
			{header: '回复时间[ReplyTime]', width:100, dataIndex:'zaddtime'},
		],
	    viewConfig	: {
	        forceFit	 : true,
	        scrollOffset : 0
	    },
	    listeners	: {
	    	'destroy':function(){
    			win && win.close();
    		},'rowdblclick':function(grid, index, e){
		    	var data = grid.store.getAt(index).copy();
		    	openText(data);
		    }
    	},
	    sm			: sm,
	    stripeRows	: true,
	    tbar		: [{
			text	: '刷新[Reload]',
			iconCls	: 'icon-refresh',
			handler : function(){
				store.reload(); 
			}
	    },'-',{
			text	: '删除[Del]',
			iconCls	: 'icon-delete',
			url		: '/admin/live/basic/comments/dodelete.html',
			handler : function() {
				var rcs = sm.getSelections();
				if(Ext.isEmpty(rcs)) {
					Ext.Msg.alert(GLang['30003'], GLang['30020']);
					return;
				}
				var ids= [];
				Ext.each(rcs, function(item){
					ids.push(item.get('id'));
				});
				Ext.Msg.confirm(GLang['30003'], GLang['30025'], function(btn){
					if(btn=="yes") {
						Ext.Ajax.request({
							url		: '/admin/live/basic/comments/dodelete.html',
							params	: {'ids':ids.join(',')},
							success : function(resp, req){
								var data = Ext.decode(resp.responseText);
								if(data.code == 0) {
									store.reload(); 
								} else {
									Ext.Msg.alert(GLang['30003'], data.msg);
								}
							}
						});
					}
				});
			}
		},'-','主播[Anchor]:',{
			xtype		: 'combo',
			store		: new Ext.data.JsonStore({
				url	: '/admin/live/share/douser.html',
				autoDestroy: true,
				fields: ['id', 'name'],
				root: 'dataset'
			}),
			id	    	    : sid.refid,
			displayField	: 'name',
			valueField		: 'id',
			emptyText		: 'Selected...',
			minChars		: 1,
			 pageSize		: 10,
			listWidth		: 258,
			width			: 160,
			typeAhead		: true,
			typeAheadDelay  : 0,
			triggerAction	: 'all',
			enableKeyEvents : true,
			mode			: 'remote'
		},'时间[AddTime]:',{
			xtype       : 'datefield',
			id  		: sid.sdate,
			format      : 'Y-m-d',
			width	    : 100
		},'<->',{
			xtype       : 'datefield',
			id  		: sid.edate,
			format      : 'Y-m-d',
			width	    : 100
		},'-',{
			text			: GLang['30024'],
			iconCls			: 'icon-search',
			handler: function() {
				store.baseParams.refid    = Ext.getCmp(sid.refid).getValue();
				store.baseParams.sdate    = Ext.getCmp(sid.sdate).getValue();
				store.baseParams.edate    = Ext.getCmp(sid.edate).getValue();
				store.reload(); 
			}
		}],
		bbar		: new Ext.PagingToolbar({
			pageSize	: main.pageSize,
			store		: store,
			displayInfo	: true
		})
	};
	return grid;
}();